package com.xinqi.modules.sys.complaint.manager.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.base.enums.YesNoNumberEnum;
import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.core.utils.MessageUtils;
import com.xinqi.common.mybatis.data.service.impl.BaseServiceImpl;
import com.xinqi.modules.sys.complaint.domain.ComplaintEntity;
import com.xinqi.modules.sys.complaint.dto.req.AccountUnblockingQueryDTO;
import com.xinqi.modules.sys.complaint.dto.req.ComplaintQueryDTO;
import com.xinqi.modules.sys.complaint.dto.rsp.ComplaintResultDTO;
import com.xinqi.modules.sys.complaint.manager.ComplaintManager;
import com.xinqi.modules.sys.complaint.mapper.ComplaintMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * 聊天投诉表管理层实现
 *
 * @author: yyzhenn
 * @date: 2023/04/23
 */
@Service
@RequiredArgsConstructor
public class ComplaintManagerImpl extends BaseServiceImpl<ComplaintMapper, ComplaintEntity> implements ComplaintManager {

    /**
     * 自定义分页查询
     */
    @Override
    public Page<ComplaintResultDTO> findPage(Page<Object> page, ComplaintQueryDTO query) {
        query.setIsDelete(YesNoNumberEnum.NO.getCode());
        return this.baseMapper.findPage(page, query);
    }

    /**
     * 根据id查询 聊天投诉表数据
     */
    @Override
    public ComplaintResultDTO findById(Long id) {
        CommonErrors.BAD_REQUEST.check(Objects.nonNull(id), MessageUtils.message("complaint.id.not.blank"));
        return this.baseMapper.findById(id);
    }

    /**
     * 获取需要解封的数据
     *
     * @param query
     * @return
     */
    @Override
    public List<ComplaintEntity> selectBan(AccountUnblockingQueryDTO query) {
        return this.baseMapper.selectBan(query);
    }

}
